package com.pactera.madp.cp.controller.oms.role;

import com.pactera.madp.common.core.util.R;
import com.pactera.madp.cp.api.vo.role.RoleVo;
import com.pactera.madp.cp.api.vo.role.UserVo;
import com.pactera.madp.cp.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
@Api(tags = "用户角色")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/query")
    @ApiOperation("全部角色查询")
    public R query() {
        List<RoleVo> vos = roleService.selectAll();
        return R.ok(vos);
    }

    @ApiOperation("查询所有角色用户")
    @GetMapping("/queryUserById")
    public R queryUserById(Integer roleId){
        List<UserVo> userVos = roleService.queryUserById(roleId);
        return R.ok(userVos);
    }

}
